<!--
 * @FilePath     : /layui/demo/1545.html
 * @Description  : 自定义`多选选中`渲染
 * @Date         : 2025-02-24 11:39
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-02-24 13:14
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
  </head>
  <body>
    <div id="demo1" class="xm-select-demo"></div>

    <script src="/xm-select/dist/xm-select.js"></script>
    <script>
      // 1、定义 选项对应的图标；
      var icons = ['layui-icon layui-icon-face-smile', 'layui-icon layui-icon-cellphone']

      var demo1 = xmSelect.render({
        el: '.xm-select-demo',
        data: [
          { group: 1, name: '张三', value: 'zhangsan', selected: true },
          { group: 0, name: '李四', value: 'lisi', selected: true },
          { group: 1, name: '王五', value: 'wangwu' },
        ],

        // 2、自定义多选中时的样式
        model: {
          label: {
            block: {
              template: function (item, sels) {
                return '<i class="' + icons[item.group] + '"></i>' + item.name
              },
            },
          },
        },
      })
    </script>
  </body>
</html>
